package com.slwu.d;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

public class RandomDoubleColorBall {

    public static void main(String[] args) {
        System.out.println("今日预测号码：");
        for (int i = 0; i < 5; i++) {
            System.out.println(generateRandomDoubleColorBall());
        }
    }

    private static String generateRandomDoubleColorBall() {
        List<Integer> redBalls = generateUniqueNumbers(1, 33, 6);
        int blueBall = generateUniqueNumbers(1, 16, 1).get(0);
        return redBalls.stream().map(String::valueOf).collect(Collectors.joining("\t")) + " | " + blueBall;
    }

    // 生成不重复的随机数
    private static List<Integer> generateUniqueNumbers(int min, int max, int count) {
        List<Integer> numbers = new ArrayList<>();
        Random random = new Random();
        while (numbers.size() < count) {
            int num = random.nextInt(max) + min;
            if (!numbers.contains(num)) {
                numbers.add(num);
            }
        }
        return numbers.stream().sorted().collect(Collectors.toList());
    }
}
